/**
 * 
 */
package com.ideal.trsdata.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ideal.trsdata.dao.ITrsDataDao;
import com.ideal.trsdata.model.ProductModel;
import com.ideal.trsdata.util.TrsDataConfig;


/**
 * @作者 杨鹏
 * @创建日期 Jun 1, 2009
 */
@Service
@Transactional
public class TrsPropertyService {
	@Autowired
	ITrsDataDao trsDataDao;
	
	public String findPropertyValue(String fieldName,String tableName,Integer productid)throws Exception{
		TrsDataConfig.map.put("fieldname",fieldName);
		TrsDataConfig.map.put("tableName",tableName);
		TrsDataConfig.map.put("productid",productid);
		
		return trsDataDao.getPropertyValue(TrsDataConfig.map);
	}
	
	
	public String findPropertyId(String fieldName)throws Exception{
		
		return null;
	}
	
	public List<ProductModel> findPropertyList(String fieldName,String tableName,Integer productid)throws Exception{
		TrsDataConfig.map.put("tableName",tableName);
		TrsDataConfig.map.put("productid",productid);
		TrsDataConfig.map.put("fieldname",fieldName);
		return trsDataDao.getProperyList(TrsDataConfig.map);
	}
	
	public static void main(String[] args) {
		ApplicationContext ctx=new FileSystemXmlApplicationContext("conf/bean.xml");
		TrsPropertyService service=(TrsPropertyService)ctx.getBean("trsProService");
		
		try {
			String fieldName="'"+TrsDataConfig.RECOMMENDSPEC+"','"+TrsDataConfig.RANK_STRATEGY+"','"+TrsDataConfig.RANK_POSITION+"','"+TrsDataConfig.BALANCE_VALUE+"'";
			List<ProductModel> ll=service.findPropertyList(fieldName,TrsDataConfig.PropertyTable,924);
			System.out.println(ll.size());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
